package dao.impl;

import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;

import dao.MeetingDao;
import po.meeting.Meeting;

public class MeetingDaoimpl implements MeetingDao{

	private List<Meeting> meet;
	
	public MeetingDaoimpl() {
		meet = new LinkedList<>();
	}
	
	@Override
	public boolean insert(Meeting t) {
		if(meet.contains(t)) {
			return false;	
		}
		return meet.add(t);
		
	}

	@Override
	public boolean update(Meeting t) {
		int index = meet.indexOf(t);
		if(index == -1) {
			return false;	
		}else {
			meet.set(index, t);
			return true;
		}
		
	}

	@Override
	public boolean delete(int id) {
		Iterator<Meeting> it = meet.iterator();
		while(it.hasNext()) {
			Meeting next = it.next();
			if(next.getMeetId() == id) {
				next.getMeetTime();
				return true;
			}
		}
		
		return false;
	}

	@Override
	public Meeting selectById(int id) {
		Iterator<Meeting> it = meet.iterator();
		while(it.hasNext()) {
			Meeting next = it.next();
			if(next.getMeetId() == id) {
				return next;
			}
		}
			
		return null;
	}

	@Override
	public List<Meeting> selectAll() {
		List<Meeting> copy = new LinkedList<>();
		return copy;
	}

}
